<?php

include dirname(dirname(dirname(__FILE__))) . '/include/common.php';

class webServiceGetEvent extends core {

    public function process() {
        $event_id = $this->db->escape(trim($_POST['event_id']));
        $user_id = intval($_POST['user_id']);
        $data = $this->db->get_row("SELECT * FROM events WHERE event_id=$event_id AND `user_id`='$user_id'");
        if ($data) {
            
            if ($data->end_time == $data->start_date || $data->end_time=="0000-00-00 00:00:00") {
                $end_time = "";
            } else {
                $end_time = date('H:i:s', strtotime($data->end_time));
            }
            if($data->start_time=="0000-00-00 00:00:00"){
                $start_time='';
            }else{
                $start_time=date('H:i:s',strtotime($data->start_time));
            }
            $this->_JSONResponse(array('error' => 0, 'title' => $data->title, 
                'start_date' => date('Y-m-d',strtotime($data->start_date)),
                'start_time' => $start_time,
                'end_time' => $end_time, 'location' => $data->location, 
                'description' => $data->description
                ));
        } else {
            $this->_JSONResponse(array('error' => 1,'msg'=>'Event does not exist'));
        }
    }

}

$processor = new webServiceGetEvent();
$processor->process();
?>